import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';

enum ImageSource {
  /// Opens up the device camera, letting the user to take a new picture.
  camera,

  /// Opens the user's photo gallery.
  gallery,
}

class ImagePicker {
  static const MethodChannel _channel = const MethodChannel('image_picker');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future<File> pickImage(
      {@required ImageSource source,
      @required bool isHead,
      @required String color,
      bool isEnglishLanguage,
        @required String language,}) async {
    final String path = await _channel.invokeMethod<String>(
      'pickImage',
      <String, dynamic>{
        'source': source.index,
        'isHead': isHead,
        'color': color,
        'isEnglishLanguage': isEnglishLanguage,
        'language': language

      },
    );
    return path == null ? null : File(path);
  }
}
